﻿using ApiLib.Common.Attributes;
using Microsoft.AspNetCore.Mvc.Controllers;

namespace ApiLib.Models;

/// <summary>
/// 基础接口
/// </summary>
public interface IBaseUser
{
    /// <summary>
    /// 获取Sid
    /// </summary>
    string GetSid();

    /// <summary>
    /// 获取Name
    /// </summary>
    string GetName();

    /// <summary>
    /// 获取角色
    /// </summary>
    /// <returns></returns>
    HashSet<string>? GetRoles();

    /// <summary>
    /// 获取权限
    /// </summary>
    /// <returns></returns>
    HashSet<string>? GetPermissions();

    /// <summary>
    /// 初始化权限
    /// </summary>
    /// <returns></returns>
    void InitPermissions();

    /// <summary>
    /// 是否拥有权限
    /// </summary>
    /// <param name="descriptor">接口</param>
    /// <param name="attribute">特性</param>
    /// <returns></returns>
    bool HasPermission(ControllerActionDescriptor descriptor, PermissionAttribute? attribute = null);

    /// <summary>
    /// 是否超级管理员
    /// </summary>
    /// <returns></returns>
    bool IsSuperAdmin();
}